package com.jsh.result;

/**
 *
 * @brief 类简要说明
 *
 * 类详细说明
 *
 *@author
 *    - 2023/5/4  贾思浩  创建初始版本
 *
 */
public class Result <T>{
    //状态码
    private Integer code;
    //状态信息
    private String message;
    //返回数据
    private T data;

    //请求操作成功 使用的构造方法
    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    //操作成功，有响应体
    public static <T>  Result success(Integer code, String message, T data){
        return new Result (code,  message, data);
    }
    //操作成功，无响应体
    public static Result success(Integer code, String message){
        return new Result(code, message, null);
    }
    //操作失败
    public static Result error(Integer code, String message){
        return new Result(code, message, null);
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
